Guild icon
Project Sekai
🔒 BYUCTF 2023 / ✅-misc-xkcd-2637
Avatar
xkcd 2637 - 500 points
Category: Misc Description: Saw this and just couldn't resist. nc byuctf.xyz 40014 Files: No files. Tags: Medium
Sutx pinned a message to this channel. 05/19/2023 10:01 AM
Avatar
@Violin wants to collaborate 🤝
Avatar
@Legoclones wants to collaborate 🤝
Avatar
@Deleted User wants to collaborate 🤝
Avatar
Deleted User 05/19/2023 10:29 AM
doing this one
Avatar
ez chal
10:56
u gonna finish?
10:57
@Deleted User
Avatar
Deleted User 05/19/2023 10:58 AM
yeah
Avatar
im skipping it then
Avatar
Deleted User 05/19/2023 10:58 AM
give me 15 minutes
10:58
@sahuang do lego 1 for me
Avatar
im doing collision
Avatar
Deleted User 05/19/2023 11:22 AM
chall is kinda hard lol
11:22
but im almost done
Avatar
its easy
11:23
i can do in 10 min
11:23
but anyway gg
Avatar
Deleted User 05/19/2023 11:25 AM
requires four different conversion functions lmao
Avatar
@hfz wants to collaborate 🤝
Avatar
Deleted User 05/19/2023 11:31 AM
Explain xkcd is a wiki dedicated to explaining the webcomic xkcd. Go figure.
11:31
done in 5 min
11:31
running
11:37
nvm
11:37
broken
11:37
wtf
11:37
i hate this
11:38
ok i did it
11:38
nice
Avatar
@rubiya wants to collaborate 🤝
Avatar
Deleted User 05/19/2023 11:40 AM
wait what the fuck
11:40
from pwn import * def wrong_int_to_roman(num): num_str = str(num) roman_num = '' i = 0 while i < len(num_str): if num_str[i] == '1' and i + 1 < len(num_str) and num_str[i + 1] == '0': roman_num += 'X' i += 2 elif num_str[i] == '5': roman_num += 'V' i += 1 elif num_str[i] == '1': roman_num += 'I' i += 1 else: i += 1 return roman_num def wrong_roman_to_int(s): result_str = '' for c in s: if c == 'X': result_str += '10' elif c == 'V': result_str += '5' elif c == 'I': result_str += '1' return int(result_str) def roman_to_int(s): roman_dict = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000} result = 0 for i in range(len(s)): if i > 0 and roman_dict[s[i]] > roman_dict[s[i - 1]]: result += roman_dict[s[i]] - 2 * roman_dict[s[i - 1]] else: result += roman_dict[s[i]] return result def int_to_roman(num): val = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ] syb = [ "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" ] roman_num = '' i = 0 while num > 0: for _ in range(num // val[i]): roman_num += syb[i] num -= val[i] i += 1 return roman_num def parse_expression(expr): # Remove the equals sign and any whitespace from the expression expr = expr.replace('=', '') expr = expr.replace(' ', '') # Find the operator and split the expression into operands operator = None operands = [] for op in ['+', '-', '*', '/']: if op in expr: operator = op operands = expr.split(op) break # Convert the operands to integers operands = [roman_to_int(wrong_int_to_roman(operand)) for operand in operands] print(operands) # Perform the operation if operator == '+': result = operands[0] + operands[1] elif operator == '-': result = operands[0] - operands[1] elif operator == '*': result = operands[0] * operands[1] elif operator == '/': result = operands[0] // operands[1] # Convert the result back to roman numerals result = wrong_roman_to_int(int_to_roman(result)) # Return the result return result def solve(): p = remote("byuctf.xyz", 40014) text = p.recvuntilS("=") problem = text.split("\n")[1] p.sendline(str(parse_expression(problem))) print(p.recvallS()) if __name__ == "__main__": solve()
11:40
here is script so far lmao
11:40
debugging
11:42
1015 * 1010 = 101010
11:42
right?
11:42
because 1015 * 1010 = XIV * XX = 14 * 20
11:42
oh
11:42
its wrong
11:43
oh i see what i did
11:43
simple mistake
Avatar
Deleted User 05/19/2023 11:51 AM
51 + 1010101 = [6, 31] 37 XXXVII 101010511
11:52
conversion shoudl be this, no?
11:52
looks correct
11:53
oh i see what's wrong
11:54
my int_to_roman is adding extra symbols
12:01
OK NICE ITS RIGHT
12:01
LETS GO
12:05
running solve
12:06
well i got to 500 but im getting eoferror
12:07
Avatar
io.interact
12:11
after 500
12:12
oh interactive
12:12
true
12:13
nope didnt work
12:13
debug my script pls @sahuang
12:13
from pwn import * def wrong_int_to_roman(num): num_str = str(num) roman_num = '' i = 0 while i < len(num_str): if num_str[i] == '1' and i + 1 < len(num_str) and num_str[i + 1] == '0': roman_num += 'X' i += 2 elif num_str[i] == '5': roman_num += 'V' i += 1 elif num_str[i] == '1': roman_num += 'I' i += 1 else: i += 1 return roman_num def wrong_roman_to_int(s): result_str = '' for c in s: if c == 'M': result_str += '1000' elif c == 'D': result_str += '500' elif c == 'C': result_str += '100' elif c == 'L': result_str += '50' elif c == 'X': result_str += '10' elif c == 'V': result_str += '5' elif c == 'I': result_str += '1' return int(result_str) def roman_to_int(s): roman_dict = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000} result = 0 for i in range(len(s)): if i > 0 and roman_dict[s[i]] > roman_dict[s[i - 1]]: result += roman_dict[s[i]] - 2 * roman_dict[s[i - 1]] else: result += roman_dict[s[i]] return result def int_to_roman(num): val = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ] syb = [ "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" ] roman_num = '' i = 0 while num > 0: for _ in range(num // val[i]): roman_num += syb[i] num -= val[i] i += 1 return roman_num def parse_expression(expr): # Remove the equals sign and any whitespace from the expression expr = expr.replace('=', '') expr = expr.replace(' ', '') # Find the operator and split the expression into operands operator = None operands = [] for op in ['+', '-', '*', '/']: if op in expr: operator = op operands = expr.split(op) break # Convert the operands to integers operands = [roman_to_int(wrong_int_to_roman(operand)) for operand in operands] # Perform the operation if operator == '+': result = operands[0] + operands[1] elif operator == '-': result = operands[0] - operands[1] elif operator == '*': result = operands[0] * operands[1] elif operator == '/': result = operands[0] // operands[1] result = wrong_roman_to_int(int_to_roman(result)) # Return the result return result def solve(): p = remote("byuctf.xyz", 40014) text = p.recvuntilS("=") problem = text.split("\n")[1] p.sendline(str(parse_expression(problem))) for i in range(999): if("=" in problem): problem = p.recvuntilS("=") p.sendline(str(parse_expression(problem))) print(f'{i}: {problem}') else: p.interactive() # if("}" in problem): # print(p.recvallS()) if __name__ == "__main__": solve()
Avatar
im out
Avatar
Deleted User 05/19/2023 12:13 PM
wt
12:13
f
Avatar
lunch
12:14
lol
12:14
try other chals
12:14
i can do it ez
Avatar
Deleted User 05/19/2023 12:33 PM
kk
12:33
@sahuang lmk when you solve
12:34
or when you see what is wrong so I can solve
Avatar
k ill
12:34
still outside
Avatar
Deleted User 05/19/2023 12:38 PM
wait ik how to fix this
12:38
just iterate 497 times
12:38
solve last one manually
12:38
lmao
Avatar
lol
Avatar
Deleted User 05/19/2023 12:40 PM
well fuck
12:40
12:42
lmao
12:45
solved
Avatar
Avatar
Deleted User b317dd6e
used /ctf solve
✅ Challenge solved.
Avatar
Deleted User 05/19/2023 12:46 PM
shittiest script ever LOL]
12:46
from pwn import * def wrong_int_to_roman(num): num_str = str(num) roman_num = '' i = 0 while i < len(num_str): if num_str[i] == '1' and i + 1 < len(num_str) and num_str[i + 1] == '0': roman_num += 'X' i += 2 elif num_str[i] == '5': roman_num += 'V' i += 1 elif num_str[i] == '1': roman_num += 'I' i += 1 else: i += 1 return roman_num def wrong_roman_to_int(s): result_str = '' for c in s: if c == 'M': result_str += '1000' elif c == 'D': result_str += '500' elif c == 'C': result_str += '100' elif c == 'L': result_str += '50' elif c == 'X': result_str += '10' elif c == 'V': result_str += '5' elif c == 'I': result_str += '1' return int(result_str) def roman_to_int(s): roman_dict = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000} result = 0 for i in range(len(s)): if i > 0 and roman_dict[s[i]] > roman_dict[s[i - 1]]: result += roman_dict[s[i]] - 2 * roman_dict[s[i - 1]] else: result += roman_dict[s[i]] return result def int_to_roman(num): val = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ] syb = [ "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" ] roman_num = '' i = 0 while num > 0: for _ in range(num // val[i]): roman_num += syb[i] num -= val[i] i += 1 return roman_num def parse_expression(expr): # Remove the equals sign and any whitespace from the expression expr = expr.replace('=', '') expr = expr.replace(' ', '') # Find the operator and split the expression into operands operator = None operands = [] for op in ['+', '-', '*', '/']: if op in expr: operator = op operands = expr.split(op) break # Convert the operands to integers operands = [roman_to_int(wrong_int_to_roman(operand)) for operand in operands] # Perform the operation if operator == '+': result = operands[0] + operands[1] elif operator == '-': result = operands[0] - operands[1] elif operator == '*': result = operands[0] * operands[1] elif operator == '/': result = operands[0] // operands[1] result = wrong_roman_to_int(int_to_roman(result)) # Return the result return result def solve(): p = remote("byuctf.xyz", 40014) text = p.recvuntilS("=") problem = text.split("\n")[1] p.sendline(str(parse_expression(problem))) for i in range(499): if("=" in problem): problem = p.recvuntilS("=") p.sendline(str(parse_expression(problem))) print(f'{i}: {problem}') p.interactive() # if("}" in problem): # print(p.recvallS()) if __name__ == "__main__": solve()
Avatar
nice!
Exported 86 message(s)